package com.darwin.darwinUI.controls
{
	import com.darwin.darwinUI.general.DarwinFont;
	import com.darwin.darwinUI.uiconst.UIAlign;
	
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.net.FileFilter;

	/**
	 * 携带文本标签的按钮
	 * @author Roland
	 */
	public class LabelButton extends Button
	{
		private var _label:Label;


		/**
		 *	实例化一个带文本标签的按钮 
		 * @param text 按钮上要显示的文本
		 * @param background 按钮皮肤 
		 * @param backgroundSkin 背景皮肤资源信息字符串
		 * @param font 文本字体
		 * @param textTop 文本的上边距
		 * 
		 */
		public function LabelButton(text:String = "", background:DisplayObject = null,backgroundSkin:String = "", font:DarwinFont = null,textTop:Number = 0)
		{
			if(background != null)
			{
				this.background = background;
			}
			if(backgroundSkin != "")
			{
				this.backgroundSkin = backgroundSkin;
			}
			_label = new Label(text,font,textTop);
			_label.widthAuto = true;
			_label.heightAuto = true;
			addChild(_label);
		}
		
		
		/**
		 *	按钮上的文本标签，设置此属性将完全替换按钮上的原有Label
		 */
		public function get label():Label
		{
			return _label;
		}
		
		/**
		 * @private
		 */
		public function set label(value:Label):void
		{
			if(_label)
			{
				removeChild(_label);
			}
			_label = value;
			addChild(_label);
		}
		
//		/**
//		 *	根据 labelAlign属性重定位文本标签的位置
//		 */
		/*private function locateLabel():void
		{
			
		}*/

		/**
		 *	按钮上要显示的文本 
		 */
		public function get text():String
		{
			return _label.text;
		}

		/**
		 * @private
		 */
		public function set text(value:String):void
		{
			_label.text = value;
		}
		

		/**
		 *	按钮上文本标签的透明度 
		 */
		public function get textAlpha():Number
		{
			return _label.textAlpha;
		}

		/**
		 * @private
		 */
		public function set textAlpha(value:Number):void
		{
			_label.textAlpha = value;
		}


		/**
		 *	按钮上文本标签的颜色 
		 */
		public function get textColor():uint
		{
			return _label.textColor;
		}

		/**
		 * @private
		 */
		public function set textColor(value:uint):void
		{
			_label.textColor = value;
		}
		
		/**
		 *	按钮上文本标签的滤镜 
		 */
		public function get textFilters():Array
		{
			return _label.textFilters;
		}

		/**
		 * @private
		 */
		public function set textFilters(value:Array):void
		{
			_label.textFilters = value;
		}

		/**
		 * 文本标签相对于按钮背景的x位置	 
		 */
		public function get textX():Number
		{
			return _label.x;
		}
		
		/**
		 * @private
		 */
		public function set textX(value:Number):void
		{
			_label.x = value;
		}
		
		/**
		 * 文本标签相对于按钮背景的y位置	 
		 */
		public function get textY():Number
		{
			return _label.y;
		}
		
		/**
		 * @private
		 */
		public function set textY(value:Number):void
		{
			_label.y = value;
		}
		
		
		/**
		 *	文本宽度 
		 */
		public function get textWidth():Number
		{
			return _label.textWidth;
		}

		/**
		 *	文本高度 
		 */
		public function get textHeight():Number
		{
			return _label.textHeight;
		}
		
		private var _rectVisible:Boolean = false;
		/**
		 * 显示该对象矩形 测试用 
		 * @param vaule
		 * 
		 */		
		override public function set rectVisible(vaule:Boolean):void
		{
			_rectVisible = vaule;
			this.graphics.clear();
			if(_rectVisible==true)
			{
				this.graphics.lineStyle(2,0xff0000);
				this.graphics.beginFill(0xff0000,0);
				this.graphics.drawRect(0,0,width,height);
				this.graphics.endFill();
			}
		}
		
		override public function get rectVisible():Boolean
		{
			return _rectVisible;
		}
		
	}
}